home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / sdoc210 / sdsample.frm < prev    next >
Text File  |  1995-05-07  |  3KB  |  95 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Subdoc sample project"
  4.    ClientHeight    =   5820
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1770
  7.    ClientWidth     =   7365
  8.    Height          =   6510
  9.    KeyPreview      =   -1  'True
  10.    Left            =   1035
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5820
  13.    ScaleWidth      =   7365
  14.    Top             =   1140
  15.    Width           =   7485
  16.    Begin Menu MStart 
  17.       Caption         =   "&Tile"
  18.    End
  19.    Begin Menu MFinish 
  20.       Caption         =   "&Finish"
  21.    End
  22. End
  23. DefInt A-Z
  24.  
  25. ''  This form doesn't do anything much - just a sample
  26. ''  of code for subdoc to show off with.
  27. ''  *** However try remming out the lines in MStart_Click
  28. ''      that take the loss of frame borders into account
  29. ''      and see what happens.
  30.  
  31.  
  32.  
  33. Dim T() As TILE                    ' will contain tiles
  34.  
  35. Sub MFinish_Click ()
  36.     End
  37. End Sub
  38.  
  39. Sub MStart_Click ()
  40. ''  Start the sample application:-
  41. ''      ask for name, create tiles, compute form
  42. ''      dimensions then lay out tiles.
  43. ''  *** Interesting code modification in this procedure ***
  44.  
  45. n$ = InputBox$("Please input a name", "", "Geoffrey")
  46. nc = Len(n$)
  47.  
  48.  
  49. fw = form1.Width        ' INCORRECT !!!!
  50. fh = form1.Height
  51.  
  52. '   divide form EXACTLY into NC squares each way
  53. fw = form1.Width - lostframewidthintwips()
  54. fh = form1.Height - lostframeheightintwips(True)
  55. '   rem the preceeding two lines out and see what happens
  56.  
  57.  
  58. intvlx = fw / nc         ' intervals
  59. intvly = fh / nc
  60. form1.FontSize = Tilefontsize
  61.  
  62.  
  63. ReDim T(1 To nc, 1 To nc) As TILE
  64. For r = 1 To nc
  65.     For c = 1 To nc
  66.         T(r, c).top = (r - 1) * intvly
  67.         T(r, c).left = (c - 1) * intvlx
  68.         T(r, c).bottom = (r) * intvly
  69.         T(r, c).right = (c) * intvlx
  70.         T(r, c).letter = Mid$(n$, 1 + (r + c - 2) Mod nc, 1)
  71.         T(r, c).clr = QBColor(1 + ((r + c) Mod 15))
  72.         Call showtile(r, c)
  73.     Next c
  74. Next r
  75. End Sub
  76.  
  77. Sub showtile (r, c)
  78. ''  Show the tile in the gloabl array T()
  79. ''  R and C are row and column indeces
  80. form1.DrawWidth = 1
  81. Dim ti As TILE
  82. ti = T(r, c)    ' current tile working var
  83.  
  84. Line (ti.left, ti.top)-(ti.right, ti.bottom), ti.clr, BF
  85. Line (ti.left, ti.top)-(ti.right, ti.bottom), QBColor(0), B
  86. lw = form1.TextWidth(ti.letter)
  87. lh = form1.TextHeight(ti.letter)
  88.  
  89. form1.CurrentX = (ti.left + ti.right - lw) / 2
  90. form1.CurrentY = (ti.top + ti.bottom - lh) / 2
  91. form1.Print ti.letter;
  92.  
  93. End Sub
  94.  
  95.